import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-05-28
 * Time: 14:46
 */
class Student {
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class Test {
    public static void main18(String[] args) {
        String s1 = "  wow!!! hello world!!!   ";
        System.out.println(s1);

        String s2 = s1.trim();
        System.out.println(s2);
    }
    public static void main17(String[] args) {
        String s1 = "ababcabcd";
        String s2 = s1.replace('a','k');
        System.out.println(s2);//kbkbckbcd
        String s3 = s1.replace("bc","nn");
        System.out.println(s3);
        String s4 = s1.replaceFirst("bc","nn");
        System.out.println(s4);
        String s5 = s1.replaceAll("bc","nn");
        System.out.println(s5);
    }
    public static void main16(String[] args) {
        String s1 = "abcdefgh";
        /*String s2 = s1.substring(3);
        System.out.println(s2);//"defgh"*/
        String s3 = s1.substring(3,5);//左闭右开：[3,5) "de"
        System.out.println(s3);
    }
    public static void main15(String[] args) {
        String s1 = "sdj\\djjf\\sdd";
        String[] arr = s1.split("\\\\");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
    public static void main14(String[] args) {
        String s1 = "abd.dj.df";
        String[] arr = s1.split("\\.");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
    public static void main13(String[] args) {
        String s1 = "name=dings&age=18";
        String[] arr = s1.split("&|=");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
    public static void main12(String[] args) {
        String s1 = String.valueOf(new Student("DINGS",18));
        System.out.println(s1);
    }
    public static void main11(String[] args) {
        String s1 = "abcdef";
        char[] arr = s1.toCharArray();
        for (char x: arr) {
            System.out.println(x);
        }
    }
    public static void main10(String[] args) {
        String s1 = "abcdB";
        String s2 = "LKJHG";
        String s11 = s1.toUpperCase();
        String s22 = s2.toLowerCase();
        System.out.println(s11);
        System.out.println(s22);
    }
    public static void main9(String[] args) {
        String s1 = "123";
        int a = Integer.parseInt(s1);
        double b = Double.parseDouble(s1);
        System.out.println(a + 1);
        System.out.println(b + 1);

        /*int a = 6235;
        String s1 = String.valueOf(a);
        System.out.println(s1);*/
    }
    public static void main8(String[] args) {
        String s1 = "ababcabcd";
        int ch1 = s1.lastIndexOf('a');
        System.out.println(ch1);//5
        int ch2 = s1.lastIndexOf('a',2);
        System.out.println(ch2);//2
        int ch3 = s1.lastIndexOf("abc",6);
        System.out.println(ch3);//5
    }
    public static void main7(String[] args) {
        String s1 = "ababcabcd";
        int ch1 = s1.indexOf('b');
        System.out.println(ch1);//1
        int ch2 = s1.indexOf('b',2);
        System.out.println(ch2);//3
        int ch3 = s1.indexOf("abc");
        System.out.println(ch3);//2
        int ch4 = s1.indexOf("abc",3);
        System.out.println(ch4);//5
    }
    public static void main6(String[] args) {
        String s1 = "abcdef";
        for (int i = 0; i < s1.length(); i++) {
            char ch = s1.charAt(i);
            System.out.println(ch);
        }
    }
    public static void main5(String[] args) {
        String s1 = "abc";
        String s2 = new String("abc");
        String s3 = "dnfjg";
        String s4 = "ABC";
        System.out.println(s1.compareTo(s4));
        System.out.println(s1.compareToIgnoreCase(s4));
    }
    public static void main4(String[] args) {
        String s1 = "abc";
        String s2 = new String("abc");
        String s3 = s1;
        System.out.println(s1.equals(s2));
        System.out.println(s1.equals(s3));
    }
    public static void main3(String[] args) {
        String s1 = "abc";
        String s2 = new String("abc");
        String s3 = s1;
        System.out.println(s1 == s2);
        System.out.println(s1 == s3);
    }
    public static void main2(String[] args) {
        //1.通过双引号直接定义
        String s1 = "abc";
        //2.通过new对象来定义
        String s2 = new String("abc");
        //3.通过字符数组来定义
        char[] arr = {'a','b','c'};
        String s3 = new String(arr);

    }
    public static void main(String[] args) {
        //char[] arr = {'w','s','r'};
        int[] arr2 = {1,2,3};
        //String s1 = String.valueOf(arr);
        String s2= Arrays.toString(arr2);
        /*System.out.println(arr);//wsr
        System.out.println(s1);//wsr*/
        System.out.println(s2);
    }
}
